package com.ddyx.rest;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.ddyx.service.IUserService;

@Controller
@RequestMapping("/login")
public class UserController {
	
	@Resource
	IUserService userService;
	
	/**
	 * 登录验证
	 * @param userName
	 * @param password
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, consumes = "application/json")
	public @ResponseBody String login(@RequestBody JSONObject user){
		String userName = user.getString("userName");
		String password = user.getString("password");
		return userService.checkUser(userName, password);
	}
}
